////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  modawbfaceassistv1.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "modawbfaceassistv1.h"
#include "parametersetmanager.h"

MODAWBFACEASSISTV1_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixAWBFaceAssistV1TypeClass::chromatixAWBFaceAssistV1TypeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(moduleID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(enableFlag);
    PARAMETER_INITIALIZE(faceAssistSAWeight);
    PARAMETER_INITIALIZE(FaceROICtrl);
    PARAMETER_INITIALIZE(faceDetectCtrl);
    PARAMETER_INITIALIZE(ConvSpeed);
    PARAMETER_INITIALIZE(darkThresholdData);
    PARAMETER_INITIALIZE(SatThresholdData);
    PARAMETER_INITIALIZE(confidenceLevelCount);
    PARAMETER_INITIALIZE(confidenceLevelID);
    PARAMETER_INITIALIZE(confidenceLevel);
    PARAMETER_INITIALIZE(darkSkinTargetPt);
    PARAMETER_INITIALIZE(lightSkinTargetPt);
    PARAMETER_INITIALIZE(skinTypeInterpWeightCount);
    PARAMETER_INITIALIZE(skinTypeInterpWeightID);
    PARAMETER_INITIALIZE(skinTypeInterpWeight);
    PARAMETER_INITIALIZE(AWBGainLockCtrl);
    PARAMETER_INITIALIZE(CbCrHighThreshold);
    PARAMETER_INITIALIZE(CbCrLowThreshold);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixAWBFaceAssistV1TypeClass::chromatixAWBFaceAssistV1TypeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(moduleID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(enableFlag);
    PARAMETER_INITIALIZE(faceAssistSAWeight);
    PARAMETER_INITIALIZE(FaceROICtrl);
    PARAMETER_INITIALIZE(faceDetectCtrl);
    PARAMETER_INITIALIZE(ConvSpeed);
    PARAMETER_INITIALIZE(darkThresholdData);
    PARAMETER_INITIALIZE(SatThresholdData);
    PARAMETER_INITIALIZE(confidenceLevel);
    PARAMETER_INITIALIZE(darkSkinTargetPt);
    PARAMETER_INITIALIZE(lightSkinTargetPt);
    PARAMETER_INITIALIZE(skinTypeInterpWeight);
    PARAMETER_INITIALIZE(AWBGainLockCtrl);
    PARAMETER_INITIALIZE(CbCrHighThreshold);
    PARAMETER_INITIALIZE(CbCrLowThreshold);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixAWBFaceAssistV1TypeClass::~chromatixAWBFaceAssistV1TypeClass()
{
    UnloadchromatixAWBFaceAssistV1Type(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* chromatixAWBFaceAssistV1TypeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "faceAssistV1")) == 0)
    {
        name = "faceAssistV1";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1TargetDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1TargetDataType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1TargetDataType* structure)
{
    BOOL result = TRUE;
    for (UINT32 i = 0; result && i < 2; i++)
    {
        structure->triggerType[i] = (awbFaceSATriggerCtrlType)entry->ReadEnum(&result);
    }
    result = result && awbglobalelements::awbglobalelementsClass::LoadtriggerPointType(entry, &structure->triggerPt);

    // Reading structure->triggerData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->triggerDataCount);
        structure->triggerDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->triggerData   = PARAMETER_NEW awbglobalelements::awbSATargetLevel2Type[structure->triggerDataCount];
        }
        if (!result || structure->triggerData == NULL)
        {
            structure->triggerDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->triggerDataCount; i++)
        {
            result = result && awbglobalelements::awbglobalelementsClass::LoadawbSATargetLevel2Type(pointerEntry1, &structure->triggerData[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1ConfidenceDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1ConfidenceDataType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1ConfidenceDataType* structure)
{
    BOOL result = TRUE;
    for (UINT32 i = 0; result && i < 2; i++)
    {
        structure->triggerType[i] = (awbFaceSATriggerCtrlType)entry->ReadEnum(&result);
    }
    result = result && awbglobalelements::awbglobalelementsClass::LoadtriggerPointType(entry, &structure->triggerPt);

    // Reading structure->triggerData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->triggerDataCount);
        structure->triggerDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->triggerData   = PARAMETER_NEW awbglobalelements::awbSAConfidenceLevel2Type[structure->triggerDataCount];
        }
        if (!result || structure->triggerData == NULL)
        {
            structure->triggerDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->triggerDataCount; i++)
        {
            result = result && awbglobalelements::awbglobalelementsClass::LoadawbSAConfidenceLevel2Type(pointerEntry1, &structure->triggerData[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1StatThresholdDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1StatThresholdDataType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1StatThresholdDataType* structure)
{
    BOOL result = TRUE;
    result = result && awbglobalelements::awbglobalelementsClass::LoadtriggerPointType(entry, &structure->triggerPt);

    // Reading structure->triggerData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->triggerDataCount);
        structure->triggerDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->triggerData   = PARAMETER_NEW awbglobalelements::awbTriggerDataRGBType[structure->triggerDataCount];
        }
        if (!result || structure->triggerData == NULL)
        {
            structure->triggerDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->triggerDataCount; i++)
        {
            result = result && awbglobalelements::awbglobalelementsClass::LoadawbTriggerDataRGBType(pointerEntry1, &structure->triggerData[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1FaceDetectCtrlType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1FaceDetectCtrlType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1FaceDetectCtrlType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->detectCntThreshold);
    result = result && entry->ReadInt32(&structure->nonDetectCntThreshold);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1FaceROICtrlType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1FaceROICtrlType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1FaceROICtrlType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->ROIXScale);
    result = result && entry->ReadFloat(&structure->ROIYScale);
    result = result && entry->ReadFloat(&structure->FaceSelectThreshold);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1CbCrDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1CbCrDataType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1CbCrDataType* structure)
{
    BOOL result = TRUE;
    for (UINT32 i = 0; result && i < 2; i++)
    {
        structure->triggerType[i] = (awbFaceSATriggerCtrlType)entry->ReadEnum(&result);
    }
    result = result && awbglobalelements::awbglobalelementsClass::LoadtriggerPointType(entry, &structure->triggerPt);

    // Reading structure->triggerData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->triggerDataCount);
        structure->triggerDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->triggerData   = PARAMETER_NEW awbglobalelements::awbCbCrLevel2Type[structure->triggerDataCount];
        }
        if (!result || structure->triggerData == NULL)
        {
            structure->triggerDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->triggerDataCount; i++)
        {
            result = result && awbglobalelements::awbglobalelementsClass::LoadawbCbCrLevel2Type(pointerEntry1, &structure->triggerData[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceAssistV1AWBGainLockCtrlType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadmodFaceAssistV1AWBGainLockCtrlType(
    ParameterFileSymbolTableEntry* entry,
    modFaceAssistV1AWBGainLockCtrlType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->AWBGainLockEnable);
    result = result && entry->ReadFloat(&structure->RGainPctDev);
    result = result && entry->ReadFloat(&structure->BGainPctDev);
    result = result && entry->ReadInt32(&structure->AWBGainStableCount);
    result = result && entry->ReadInt32(&structure->AWBGainLockCount);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAWBFaceAssistV1Type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::LoadchromatixAWBFaceAssistV1Type(
    ParameterFileSymbolTableEntry* entry,
    chromatixAWBFaceAssistV1Type* structure)
{
    BOOL result = TRUE;
    result = result && awbglobalelements::awbglobalelementsClass::LoadmoduleIDType(entry, &structure->moduleID);
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && entry->ReadInt32(&structure->enableFlag);
    result = result && entry->ReadFloat(&structure->faceAssistSAWeight);
    result = result && LoadmodFaceAssistV1FaceROICtrlType(entry, &structure->FaceROICtrl);
    result = result && LoadmodFaceAssistV1FaceDetectCtrlType(entry, &structure->faceDetectCtrl);
    result = result && entry->ReadFloat(&structure->ConvSpeed);
    result = result && LoadmodFaceAssistV1StatThresholdDataType(entry, &structure->darkThresholdData);
    result = result && LoadmodFaceAssistV1StatThresholdDataType(entry, &structure->SatThresholdData);

    // Reading structure->confidenceLevel from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->confidenceLevelCount);
        structure->confidenceLevelID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->confidenceLevel   = PARAMETER_NEW modFaceAssistV1ConfidenceDataType[structure->confidenceLevelCount];
        }
        if (!result || structure->confidenceLevel == NULL)
        {
            structure->confidenceLevelCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->confidenceLevelCount; i++)
        {
            result = result && LoadmodFaceAssistV1ConfidenceDataType(pointerEntry1, &structure->confidenceLevel[i]);
        }
    }
    result = result && LoadmodFaceAssistV1TargetDataType(entry, &structure->darkSkinTargetPt);
    result = result && LoadmodFaceAssistV1TargetDataType(entry, &structure->lightSkinTargetPt);

    // Reading structure->skinTypeInterpWeight from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->skinTypeInterpWeightCount);
        structure->skinTypeInterpWeightID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->skinTypeInterpWeight   = PARAMETER_NEW modFaceAssistV1ConfidenceDataType[structure->skinTypeInterpWeightCount];
        }
        if (!result || structure->skinTypeInterpWeight == NULL)
        {
            structure->skinTypeInterpWeightCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->skinTypeInterpWeightCount; i++)
        {
            result = result && LoadmodFaceAssistV1ConfidenceDataType(pointerEntry1, &structure->skinTypeInterpWeight[i]);
        }
    }
    result = result && LoadmodFaceAssistV1AWBGainLockCtrlType(entry, &structure->AWBGainLockCtrl);
    result = result && LoadmodFaceAssistV1CbCrDataType(entry, &structure->CbCrHighThreshold);
    result = result && LoadmodFaceAssistV1CbCrDataType(entry, &structure->CbCrLowThreshold);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixAWBFaceAssistV1TypeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixAWBFaceAssistV1Type::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);
    result = result && entry->ReadInt32(&structure->incr_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload modFaceAssistV1TargetDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixAWBFaceAssistV1TypeClass::UnloadmodFaceAssistV1TargetDataType(
    modFaceAssistV1TargetDataType* structure)
{
    for (UINT32 i = 0; i < structure->triggerDataCount; i++)
    {
        awbglobalelements::awbglobalelementsClass::UnloadawbSATargetLevel2Type(&structure->triggerData[i]);
    }
    PARAMETER_DELETE[] structure->triggerData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload modFaceAssistV1ConfidenceDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixAWBFaceAssistV1TypeClass::UnloadmodFaceAssistV1ConfidenceDataType(
    modFaceAssistV1ConfidenceDataType* structure)
{
    for (UINT32 i = 0; i < structure->triggerDataCount; i++)
    {
        awbglobalelements::awbglobalelementsClass::UnloadawbSAConfidenceLevel2Type(&structure->triggerData[i]);
    }
    PARAMETER_DELETE[] structure->triggerData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload modFaceAssistV1StatThresholdDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixAWBFaceAssistV1TypeClass::UnloadmodFaceAssistV1StatThresholdDataType(
    modFaceAssistV1StatThresholdDataType* structure)
{
    PARAMETER_DELETE[] structure->triggerData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload modFaceAssistV1CbCrDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixAWBFaceAssistV1TypeClass::UnloadmodFaceAssistV1CbCrDataType(
    modFaceAssistV1CbCrDataType* structure)
{
    for (UINT32 i = 0; i < structure->triggerDataCount; i++)
    {
        awbglobalelements::awbglobalelementsClass::UnloadawbCbCrLevel2Type(&structure->triggerData[i]);
    }
    PARAMETER_DELETE[] structure->triggerData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixAWBFaceAssistV1Type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixAWBFaceAssistV1TypeClass::UnloadchromatixAWBFaceAssistV1Type(
    chromatixAWBFaceAssistV1Type* structure)
{
    UnloadmodFaceAssistV1StatThresholdDataType(&structure->darkThresholdData);
    UnloadmodFaceAssistV1StatThresholdDataType(&structure->SatThresholdData);
    for (UINT32 i = 0; i < structure->confidenceLevelCount; i++)
    {
        UnloadmodFaceAssistV1ConfidenceDataType(&structure->confidenceLevel[i]);
    }
    PARAMETER_DELETE[] structure->confidenceLevel;
    UnloadmodFaceAssistV1TargetDataType(&structure->darkSkinTargetPt);
    UnloadmodFaceAssistV1TargetDataType(&structure->lightSkinTargetPt);
    for (UINT32 i = 0; i < structure->skinTypeInterpWeightCount; i++)
    {
        UnloadmodFaceAssistV1ConfidenceDataType(&structure->skinTypeInterpWeight[i]);
    }
    PARAMETER_DELETE[] structure->skinTypeInterpWeight;
    UnloadmodFaceAssistV1CbCrDataType(&structure->CbCrHighThreshold);
    UnloadmodFaceAssistV1CbCrDataType(&structure->CbCrLowThreshold);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* chromatixAWBFaceAssistV1TypeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    chromatixAWBFaceAssistV1TypeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW chromatixAWBFaceAssistV1TypeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadchromatixAWBFaceAssistV1Type(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


MODAWBFACEASSISTV1_NAMESPACE_END
